#ifndef PLUGINMGR_H
#define PLUGINMGR_H
#include <QMenuBar>
#include <Windows.h>
#include <QList>
#include <QMenu>
#include <QMap>
#include <QObject>
#include "sdocument.h"
#include "mainwindow.h"

typedef void (*tInitPointers)(ImageDocument*);

class Plugin:public QObject{
Q_OBJECT
public:
    Plugin(QString name,QMenu* menu);
    HMODULE getHandle() const;
public slots:
    void PrepareAction();
private:
    tInitPointers InitPointers;
    QMap<QAction*,FARPROC> pluginFunctions;
    QString moduleName;
    HMODULE moduleHandle;
};

class PluginMgr
{
public:
    static PluginMgr& getInstance();
    void Initialize(MainWindow* mainWindow);
    QStringList getModulesList();
    void LoadAllModules();
    bool LoadModule(QString moduleName);
    ImageDocument* getCurrentDocument();
private:
    MainWindow* mainWindow;
    QList<Plugin*> pluginsList;
    static PluginMgr* singleton;
    QMenuBar* mBar;
    QMenu* pluginMenu;
    PluginMgr();
};

#endif // PLUGINMGR_H
